﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CoroutineClazz : MonoBehaviour
{

    //协程的使用，启动调用只能放置在一次执行的函数中
    // Start is called before the first frame update

    private IEnumerator coroutine;
    void Start()
    {
        print("Starting " + Time.time + "seconds");
        coroutine = WaitAndPrint();
        StartCoroutine(coroutine);
        print("Coroutine started ");
    }

    // Update is called once per frame
    void Update()
    {
        print("Update " + Time.time + "seconds");
    }
    void LateUpadate() {
        print("Update " + Time.time + "seconds");
    }

    IEnumerator WaitAndPrint() {
        print("Coroutine method ......");
        yield return null;
        print("Coroutine ended "+ Time.time +"seconds");
    }
    

}
